package View;

import java.awt.Color;
import java.awt.GridLayout;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;
import javax.swing.Timer;

import Model.Radar;
import Model.Wereld;

public class RadarView extends JPanel implements Observer {

	private Wereld wereld;
	private Timer timer;
	private GridLayout layout;

	public RadarView(Wereld wereld) {
		wereld.addObserver(this);
		layout = new GridLayout(10, 1);
		layout.setVgap(3);
		setLayout(layout);
		setBackground(Color.GREEN.darker().darker().darker().darker());
		this.wereld = wereld;
	}

	public void refreshPanel() {
		int radarNummer = 1;
		for (Radar radar : wereld.getRadarlijst()) {
			add(new RadarPanel(radarNummer, radar));
			radarNummer++;
		}
	}

	@Override
	public void update(Observable o, Object obj) {
		removeAll();
		refreshPanel();
		revalidate();
		repaint();
	}
}
